import { AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from "axios"

type Headers = AxiosRequestHeaders & { "ob-client"?: number; "ob-sign"?: string }

export interface RequestConfig extends AxiosRequestConfig {
	headers?: Headers
	successTip?: string
	token?: string
	language?: string | number | boolean
}

export interface EAxiosResponse extends AxiosResponse {
	config: RequestConfig
}

// * 请求枚举配置
/**
 * @description：请求配置
 */
export enum ResultEnum {
	SUCCESS = 200,
	ERROR = 500,
	OVERDUE = 599,
	TIMEOUT = 15000,
	TYPE = "success",
	IP_LIMIT = 4013,
	MAINTAIN_CODE_ERROR = 4091,
	INVITATION_CODE_ERROR = 100047,
	RESET_LOGIN_PWD = 333333,
	MANY_DATA = 10028 // export many data
}

/**
 * 登录相关  20000[请重新登录]  20001[您的账号在其他端登录]  20002[您的账号已被禁用] 20004[代理账号被登录锁定] 20005[其他设备登录]
 */

export const LOGIN_CODE = [20000, 20001, 20002, 20004, 20005, 4004]

/**
 * @description：请求方法
 */
export enum RequestEnum {
	GET = "GET",
	POST = "POST",
	PATCH = "PATCH",
	PUT = "PUT",
	DELETE = "DELETE"
}

/**
 * @description：常用的contentTyp类型
 */
export enum ContentTypeEnum {
	// json
	JSON = "application/json;charset=UTF-8",
	// text
	TEXT = "text/plain;charset=UTF-8",
	// form-data 一般配合qs
	FORM_URLENCODED = "application/x-www-form-urlencoded;charset=UTF-8",
	// form-data 上传
	FORM_DATA = "multipart/form-data;charset=UTF-8"
}

// * 请求响应参数(不包含data)
export interface Result {
	code: number
	msg: string
	data: any
	message?: string
}
